<%-- 
    Document   : view_all_product
    Created on : Mar 14, 2014, 8:25:35 PM
    Author     : ahmed
--%>

<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script type="text/javascript" src="../jquery-1.11.0.min.js"></script>
        <script type="text/javascript">
            function deleteProduct(id) {
                $.get("DeleteProduct", {id: id}, function() {
                    window.history.go(0);
                })
            }
            function updateProduct(id) {
                $.get("GetMobileForUpdate", {id: id}, function() {
                    window.history.go(0);
                })
            }
            </script>
        <style type="text/css">
            .button {
                padding: 0.1em 0.5em;
                background-color: gray;
                color: white;
                font-weight: bold;
                cursor: pointer;
            }
        </style>
        <title>JSP Page</title>
    </head>
    <body>
        <a href="addProductView.jsp">
            Add New Mobile
        </a>
        <div class="products-view">
            <table border="1" id="users">
                <tr>
                    <td>ID</td>
                    <td>Name</td>
                    <td>Company</td>
                    <td>Quantity</td>
                    <td>Price</td>
                    <td>Display Size</td>
                    <td>Camera</td>
                    <td>Actions</td>
                </tr>

                <%
                    for (Object mobile : (List) request.getAttribute("viewAllMobiles")) {
                %>
                <tr>
                    <td><% int id = ((pojo.Mobile) mobile).getId(); %><%=id%></td>
                    <td><%=((pojo.Mobile) mobile).getName()%></td>
                    <td><%=((pojo.Mobile) mobile).getCompany()%></td>
                    <td><%=((pojo.Mobile) mobile).getQuantity()%></td>
                    <td><%=((pojo.Mobile) mobile).getPrice()%></td>
                    <td><%=((pojo.Mobile) mobile).getDisplaySize()%></td>
                    <td><%=((pojo.Mobile) mobile).getCamera()%></td>
                    <td>
                        <div class="update button" onclick="updateProduct(id)">Update</div>
                        <div class="delete button" onclick="deleteProduct(id)">Delete</div>
                    </td>
                </tr>
                <%
                    }
                %>
            </table>
        </div>
    </body>
</html>
